<?php

/*
 * Меппер возвращает настройки которые храняться в файле custom.json в формате json
 * 
 */
class Admin_Model_SettingsMapper{
	private $_filename;
	public function __construct($filename){
		$this->_filename = $filename;
	}
    public function getSettingsAsJSON(){
        if (!file_exists(APPLICATION_PATH . $this->_filename))
            throw new Zend_Exception ("Файл не найден");
        return file_get_contents(APPLICATION_PATH . $this->_filename);
    }
    public function setSettingsAsJSON($v){
        $f = fopen(APPLICATION_PATH . $this->_filename, "w+");
        fwrite($f,$v);
        fclose($f);
        return $this;
    }
    public function getSettings(){
        return json_decode($this->getSettingsAsJSON(), true);
    }
    public function getSetting($name){
        $all = $this->getSettings();
        return $all[$name];
    }
    
}
?>
